################################
#
#     Makefile SECONDO ASSEGNAMENTO AA 2019/20
#    
################################


# file da consegnare
# modificare se si aggiungono file
FILE_DA_CONSEGNARE=bbvs.c

# preferenze compilatore e flag di compilazione
CC=gcc
# compilazione 
CFLAGS= -Wall -pedantic -g

obj = bbvs.o



# phony targets
.PHONY: cleanall test1 test2 test3 consegna 


bbvs0 : 00test.o $(obj)
	gcc $(obj) 00test.o -o bbvs0 -lm

bbvs1 : 01test.o $(obj)
	gcc $(obj) 01test.o -o bbvs1 -lm

bbvs2 : 02test.o $(obj)
	gcc $(obj) 02test.o -o bbvs2 -lm

bbvs3 : 03test.o $(obj)
	gcc $(obj) 03test.o -o bbvs3 -lm

bbvs4 : 04test.o $(obj)
	gcc $(obj) 04test.o -o bbvs4 -lm


bbvs.o: bbvs.c bbvs.h  
01test.o: 01test.c bbvs.h   
02test.o: 02test.c bbvs.h   
03test.o: 03test.c bbvs.h   
04test.o: 04test.c bbvs.h   

bbvs: $(obj) main.o
	gcc $(obj) main.o -o bbvs -lm


cleanall: 
	-rm -f *.o *~ partita-test3.txt partita-test3b.txt ./core bbvs? bbvs



test1:
	make cleanall
	make bbvs1
	./bbvs1 
	@echo "********** Test1 superato!"

test2: 
	make cleanall
	make bbvs2
	./bbvs2
	@echo "********** Test2 superato!"

test3: 
	make cleanall
	cp DATA/partita-test3.txt .
	make bbvs3
	./bbvs3
	diff ./partita-test3.txt ./partita-test3b.txt
	@echo "********** Test3 superato!"

test4: 
	make cleanall
	make bbvs4
	./bbvs4
	@echo "********** Test4 superato!"

consegna:
	make cleanall
	make test1
	make test2
	make test3
	./gruppo-check.pl < gruppo.txt
	tar -cvf Cognome.Nome-corsoX-ar.tar ./gruppo.txt  $(FILE_DA_CONSEGNARE) 
	@echo "********** TAR creato! Rinominare e inviare in allegato a una mail al docente del proprio corso insieme a nome, cognome,  numero di matricola dei componenti del gruppo"
